package org.ucas.kgraph.entity;


import org.hibernate.annotations.*;
import org.ucas.kgraph.utils.common.RelationTypeHandler;

import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;

/**
 * 词条与词条之间的关系,目前仅包含父子关系和关联关系
 *
 * @author suemi
 */
@Entity
@Table
@TypeDefs(value = { @TypeDef(name = "relationType", typeClass = RelationTypeHandler.class) })
public class Relation extends IdEntity {

  private Long leftEnd;

  private Long rightEnd;

  private String name;

  @Column(columnDefinition = "INT")
  private Integer level; // The max level of leftEnd and rightEnd

  @Type(type = "relationType")
  private RelationType category;


  public Relation(){
    super();
  }

  public Relation(Long left, Long right, RelationType category){
    this();
    leftEnd = left;
    rightEnd = right;
    this.category=category;
  }

  public Long getLeftEnd() {
    return leftEnd;
  }

  public void setLeftEnd(Long leftEnd) {
    this.leftEnd = leftEnd;
  }

  public Long getRightEnd() {
    return rightEnd;
  }

  public void setRightEnd(Long rightEnd) {
    this.rightEnd = rightEnd;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public Integer getLevel() {
    return level;
  }

  public void setLevel(Integer level) {
    this.level = level;
  }

  public RelationType getCategory() {
    return category;
  }

  public void setCategory(RelationType category) {
    this.category = category;
  }
}
